//
// Created by YE on 2024/4/23.
//
#include "system.h"

int max_threads;

#if defined(_WIN32) || defined(_WIN64)

#define OS_NAME "Windows"

#include "windows.h"
void getSystemProcessor() {
    SYSTEM_INFO sys_info;
    GetSystemInfo(&sys_info);
    max_threads = sys_info.dwNumberOfProcessors;//WINDOWS VERSION
}

#elif defined(__linux__)

#define OS_NAME "Linux"

#include <unistd.h>
void getSystemProcessor(){
    max_threads = sysconf(_SC_NPROCESSORS_ONLN);//LINUX VERSION
}
#elif defined(__APPLE__)

#define OS_NAME "Mac OS X"

#include <sys/types.h>
#include <sys/sysctl.h>
void getSystemProcessor() {
   int numCPU;
   size_t len = sizeof(numCPU);
   sysctlbyname("hw.logicalcpu", &numCPU, &len, NULL, 0);
   max_threads = numCPU;//MACOS VERSION
}
#else
#define OS_NAME "Unknown"
#endif

